package com.jingan.nursinghome.regulatory.view;

import android.content.Context;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import cn.android.support.v7.lib.sin.crown.base.BaseView;
import cn.android.support.v7.lib.sin.crown.utils.ProportionUtils;

/**
 * Created by 彭治铭 on 2017/11/3.
 */

public class ClearView extends BaseView {
    public ClearView(Context context) {
        super(context);
        init();
    }

    public ClearView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    int width = ProportionUtils.getInstance().adapterInt(150);

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        //super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension(width, width);
    }

    BlurMaskFilter blurMaskFilter = new BlurMaskFilter(width / 20, BlurMaskFilter.Blur.SOLID);

    private void init() {
        setLayerType(View.LAYER_TYPE_SOFTWARE, paint);
        setMainOrSub(false);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        paint.setColor(Color.parseColor("#0080C0"));
        paint.setMaskFilter(blurMaskFilter);
        canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 3, paint);
        textPaint.setColor(Color.WHITE);
        textPaint.setTextAlign(Paint.Align.CENTER);
        canvas.drawText("清除", getWidth() / 2, getHeight() / 2 + TextSize / 3, textPaint);
    }
}
